import { request } from '@umijs/max';

// 获取学校列表
export async function getSchoolList(params: API.SchoolQueryParams) {
  return request<API.SchoolList>('/api/school', {
    method: 'GET',
    params,
  });
}

// 获取学校详情
export async function getSchoolDetail(id: string) {
  return request<{
    success: boolean;
    message?: string;
    data: API.School;
  }>(`/api/school/${id}`, {
    method: 'GET',
  });
}

// 创建学校
export async function createSchool(data: API.SchoolCreateParams) {
  return request<{
    success: boolean;
    message?: string;
    data: API.School;
  }>('/api/school', {
    method: 'POST',
    data,
  });
}

// 更新学校
export async function updateSchool(id: string, data: API.SchoolUpdateParams) {
  return request<{
    success: boolean;
    message?: string;
    data: API.School;
  }>(`/api/school/${id}`, {
    method: 'PUT',
    data,
  });
}

// 删除学校
export async function deleteSchool(id: string) {
  return request<{
    success: boolean;
    message?: string;
  }>(`/api/school/${id}`, {
    method: 'DELETE',
  });
}
